package 二叉树相关问题.中度题;

import java.util.LinkedList;

public class 完全二叉树校验 {
    public boolean isCompleteTree(TreeNode root) {
        if (root==null)
            return true;
        LinkedList<TreeNode> list = new LinkedList<>();
        list.addLast(root);
        TreeNode cur;
        while ((cur=list.removeFirst())!=null){
            list.addLast(cur.left);
            list.addLast(cur.right);
        }
        while (!list.isEmpty()){
            if (list.removeLast()!=null)
                return false;
        }
        return true;
    }
}
